package com.sky.dto;

import com.sky.entity.SetmealDish;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SetmealDTO implements Serializable {

    //添加组
    public interface Save{}
    //修改组
    public interface Update{}

    @Null(groups = Save.class,message = "添加时,id不能有值")
    @NotNull(groups = Update.class,message = "修改时,id不能为空")
    private Long id;

    //分类id
    @NotNull(groups = {Save.class,Update.class},message = "分类id不能为空")
    private Long categoryId;

    //套餐名称
    @Length(min = 2,max = 20,groups = {Save.class,Update.class},message = "套餐名称请输入2-20个字符")
    private String name;

    //套餐价格
    @Range(min = 0,max = 9999,groups = {Save.class,Update.class},message = "菜品价格在0~9999之间")
    @Digits(integer = 4,fraction = 2,groups = {Save.class,Update.class},message = "菜品价格保留两位小数")
    private BigDecimal price;

    //状态 0:停用 1:启用
    @Range(min = 0,max = 1,groups = {Save.class,Update.class},message = "错误参数")
    private Integer status;

    //描述信息
    private String description;

    //图片
    @URL(groups = {Save.class,Update.class},message = "图片地址错误")
    private String image;


    //套餐菜品关系
    @NotEmpty(groups = {Save.class,Update.class},message = "套餐下没有任何菜品,需要添加菜品")
    private List<SetmealDish> setmealDishes = new ArrayList<>();

}
